import task from "@/utils/request";
// 用户管理
export default {
test(data) {
  return task({
    url: "/api/test/",
    method: "post",
    data
  });
},
  sendSms(phone,data) {
    return task({
      url: "/api/send_sms/"+phone+"/",
      method: "get",
      params:data
    });
  },
  accountsUsersRestPwd(data) {
    return task({
      url: "/api/accounts/users/restpwd/",
      method: "post",
      data
    });
  },
  // 登录
  login(data) {
    return task({
      url: "/api/accounts/login/",
      method: "post",
      data
    });
  },
  //手机验证码登录
  loginByCode(data) {
    return task({
      url: "/api/accounts/sms/login/",
      method: "post",
      data
    });
  },
  // 通过token登录
  getLoginUrl(params) {
    return task({
      url: "/api/oauth/login_url/",
      method: "get",
      params
    });
  },
  authLogin(params) {
    return task({
      url: "/api/oauth/login/",
      method: "get",
      params
    });
  },
  //退出登录
  loginOut() {
    return task({
      url: "/api/oauth/logout/",
      method: "get"
    });
  },
  //更新缓存
  updateCache() {
    return task({
      url: "/api/accounts/update/cache/",
      method: "get"
    });
  },
  /*
   *
   * 以下是用工作台模块所需要的接口
   *
   *
   * */
  // 获取工单模块列表
  getMyBacklogList(params) {
    return task({
      url: "/api/tickets/",
      method: "get",
      params
    });
  },
  //获得所有待办待阅
  getTicketsDuty(params) {
    return task({
      url: "/api/tickets/duty/",
      method: "get",
      params:params
    });
  },
  // 获取工单新建表单
  getWONewForm(id) {
    return task({
      url: "/api/workflows/" + id + "/init_state/",
      method: "get"
    });
  },
  // 新建工单
  submitWorkOrder(data) {
    return task({
      url: "/api/tickets/",
      method: "post",
      data
    });
  },
  // 工单留言
  WOLeaveAMessage(id, data) {
    return task({
      url: "/api/tickets/" + id + "/comments/",
      method: "post",
      data
    });
  },
  /*
   *
   * 以下是用户列表模块所需要的接口
   *
   *
   * */
  //获取用户列表
  getUserList(data) {
    return task({
      url: "/api/accounts/users/?" + data,
      method: "get"
    });
  },
  //获取用户简要信息列表(搜索)
  getSimpleUser(value) {
    return task({
      url: "/api/accounts/users/simple/?search_value=" + value,
      method: "get"
    });
  },

  //以下是工作流模块的接口
  getWorkflows(params) {
    return task({
      url: "/api/workflows/",
      method: "get",
      params
    });
  },

  //获取用户管理的工作流信息
  getUserWorkflows(adminId) {
    return task({
      url: "/api/workflows/" + adminId+"/",
      method: "get"
    });
  },
  //获取通知类型
  getNotices(data) {
    return task({
      url: "/api/workflows/simple_custom_notices/?" + data,
      method: "get"
    });
  },
  //获取API相关
  getToken(data) {
    return task({
      url: "/api/accounts/simple_app_token/?" + data,
      method: "get"
    });
  },
  //获取全部simpleUser列表
  getAllSimpleUser(params) {
    return task({
      url: "/api/accounts/users/simple/",
      method: "get",
      params:params
    });
  },
  //获取部门列表(简易)
  getSimpleDeptList(data) {
    return task({
      url: "/api/accounts/depts/simple/",
      method: "get",
      params:data
    });
  },
  //编辑工作流基本信息
  editWorkflows(id, data) {
    return task({
      url: "/api/workflows/" + id + "/",
      method: "put",
      data
    });
  },
  //删除工作流基本信息
  deleteWorkflows(id) {
    return task({
      url: "/api/workflows/" + id + "/",
      method: "delete"
    });
  },
  addWorkflows(data) {
    return task({
      url: "/api/workflows/",
      method: "post",
      data
    });
  },

  //以下是自定义字段模块
  searchFieldData(id, value) {
    return task({
      url: "/api/workflows/" + id + "/custom_fields/?search_value=" + value,
      method: "get"
    });
  },
  getAllField(data) {
    return task({
      url: "/api/workflows/custom_fields/?" + data,
      method: "get"
    });
  },
  getField(id, data) {
    return task({
      url: "/api/workflows/" + id + "/custom_fields/?" + data,
      method: "get"
    });
  },
  getFieldSimple(id, data) {
    return task({
      url: "/api/workflows/" + id + "/custom_fields/simple/",
      method: "get",
      params:data
    });
  },
  editAllField(fieldId, data) {
    return task({
      url: "/api/workflows/custom_fields/" + fieldId + "/",
      method: "put",
      data
    });
  },
  editField(id, fieldId, data) {
    return task({
      url: "/api/workflows/" + id + "/custom_fields/" + fieldId + "/",
      method: "put",
      data
    });
  },
  addAllField(data) {
    return task({
      url: "/api/workflows/custom_fields/",
      method: "post",
      data
    });
  },
  addField(id, data) {
    return task({
      url: "/api/workflows/" + id + "/custom_fields/",
      method: "post",
      data
    });
  },
  delAllField(dedId) {
    return task({
      url: "/api/workflows/custom_fields/" + dedId + "/",
      method: "delete"
    });
  },
  dedField(id, dedId) {
    return task({
      url: "/api/workflows/" + id + "/custom_fields/" + dedId + "/",
      method: "delete"
    });
  },

  /*
   * 以下是 状态 模块
   *
   * */

  //搜索状态
  searchState(id, value) {
    return task({
      url: "/api/workflows/" + id + "/states/?search_value=" + value,
      method: "get"
    });
  },
  //查所有列表
  getAllState(id) {
    return task({
      url: "/api/workflows/" + id + "/states/state/",
      method: "get"
    });
  },
  //获取状态列表
  getState(id, data) {
    return task({
      url: "/api/workflows/" + id + "/states/?" + data,
      method: "get"
    });
  },
  getSimpleState(id, data) {//获取所有不分页节点
    return task({
      url: "/api/workflows/" + id + "/states/simple/",
      method: "get",
      params:data
    });
  },
  editState(id, stateId, data) {
    return task({
      url: "/api/workflows/" + id + "/states/" + stateId + "/",
      method: "put",
      data
    });
  },
  addState(id, data) {
    return task({
      url: "/api/workflows/" + id + "/states/",
      method: "post",
      data
    });
  },
  dedState(id, dedId) {
    return task({
      url: "/api/workflows/" + id + "/states/" + dedId + "/",
      method: "delete"
    });
  },

  /*
   * 以下是流转模块
   *
   * */

  //搜索功能
  searchTransitions(id, value) {
    return task({
      url: "/api/workflows/" + id + "/transitions/?search_value=" + value,
      method: "get"
    });
  },

  //获取目标状态和源状态
  getNewState(id, data) {
    return task({
      url: "/api/workflows/" + id + "/states/?" + data,
      method: "get"
    });
  },

  getTransitions(id, data) {
    return task({
      url: "/api/workflows/" + id + "/transitions/?" + data,
      method: "get"
    });
  },

  editTransitions(id, tranId, data) {
    return task({
      url: "/api/workflows/" + id + "/transitions/" + tranId + "/",
      method: "put",
      data
    });
  },
  addTransitions(id, data) {
    return task({
      url: "/api/workflows/" + id + "/transitions/",
      method: "post",
      data
    });
  },

  //删除流转
  dedTransitions(id, tranId) {
    return task({
      url: "/api/workflows/" + id + "/transitions/" + tranId + "/",
      method: "delete"
    });
  },
  changTicketsStatus(id, data) {
    return task({
      url: "/api/tickets/" + id + "/status/",
      method: "post",
      data
    });
  },
  getSimpleDepts3(data) {
    return task({
      url: "/api/accounts/simple_depts3/",
      method: "get",
      params:data
    });
  },
};
